/**
 * 
 */
var ListImportProductController = function($scope, $http, PaginatorRR, $log) {

	$scope.pageSize = 10;
	$scope.orders = [];
	var fetchFunction = function(currentPage, limit, propId, callback) {

		$http.get("../managerProduct/list", {
			params : {
				'pageSize' : limit,
				'cpage' : currentPage,
				'isIn' : propId
			}
		}).success(callback);
	}

	$scope.orders[0] = PaginatorRR(fetchFunction, $scope.pageSize, false);
	$log.info($scope.orders[0]);

	$scope.getTab = function(propId) {
		if (propId == "0") {
			$scope.orders[propId] = PaginatorRR(fetchFunction, $scope.pageSize, false);
		} else {
			$scope.orders[propId] = PaginatorRR(fetchFunction, $scope.pageSize, true);
		}

	}

	$scope.updateActive = function(item) {

		$('#my-confirm').modal({
			relatedTarget : this,
			onConfirm : function(options) {
				$http({
					method : "post",
					url : "../managerProduct/active",
					data : $.param({
						'id' : item.id
					}), // pass in data as
					headers : {
						'Content-Type' : 'application/x-www-form-urlencoded'
					}
				}).success(function(response) {
					if (response.code == 1) {
						sweetAlert("已经入库");
						$scope.orders[0] = PaginatorRR(fetchFunction, $scope.pageSize, false);
					} else {
						sweetAlert(response.info);
						return;
					}
				});
			},
			onCancel : function() {
			}
		});
	}
	
	
}